package com.master.lambda;

import java.util.function.Consumer;
import java.util.function.Predicate;

import lombok.AllArgsConstructor;
import lombok.Data;

public /*@Data @AllArgsConstructor*/ class Order {
    private long id;
    private double payment;
    private double freight;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public double getPayment() {
        return payment;
    }

    public void setPayment(double payment) {
        this.payment = payment;
    }

    public double getFreight() {
        return freight;
    }

    public void setFreight(double freight) {
        this.freight = freight;
    }

    public Order(long id, double payment, double freight) {
        this.id = id;
        this.payment = payment;
        this.freight = freight;
    }


    // 优惠政策
    public Order discount(Order order, Predicate<Order> predicate, Consumer<Order> consumer) {
        // 满足Predicate的条件，返回true
        if (predicate.test(order)) {
            // 接收订单对象，对订单对象进行处理
            consumer.accept(order);
        }

        return order;
    }
}
